package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingPhysicalConditionLayout;
import com.ruoyi.ring.service.IRingPhysicalConditionLayoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 身体状况布局Controller
 * 
 * @author liuwp
 * @date 2025-10-09
 */
@RestController
@RequestMapping("/ring/ring_physical_condition_layout")
public class RingPhysicalConditionLayoutController extends BaseController
{
    @Autowired
    private IRingPhysicalConditionLayoutService ringPhysicalConditionLayoutService;

    /**
     * 查询身体状况布局列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_physical_condition_layout:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingPhysicalConditionLayout ringPhysicalConditionLayout)
    {
        startPage();
        List<RingPhysicalConditionLayout> list = ringPhysicalConditionLayoutService.selectRingPhysicalConditionLayoutList(ringPhysicalConditionLayout);
        return getDataTable(list);
    }

    /**
     * 导出身体状况布局列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_physical_condition_layout:export')")
    @Log(title = "身体状况布局", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingPhysicalConditionLayout ringPhysicalConditionLayout)
    {
        List<RingPhysicalConditionLayout> list = ringPhysicalConditionLayoutService.selectRingPhysicalConditionLayoutList(ringPhysicalConditionLayout);
        ExcelUtil<RingPhysicalConditionLayout> util = new ExcelUtil<RingPhysicalConditionLayout>(RingPhysicalConditionLayout.class);
        util.exportExcel(response, list, "身体状况布局数据");
    }

    /**
     * 获取身体状况布局详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_physical_condition_layout:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringPhysicalConditionLayoutService.selectRingPhysicalConditionLayoutById(id));
    }

    /**
     * 新增身体状况布局
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_physical_condition_layout:add')")
    @Log(title = "身体状况布局", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingPhysicalConditionLayout ringPhysicalConditionLayout)
    {
        ringPhysicalConditionLayout.setUserId(SecurityUtils.getUserId());
        return toAjax(ringPhysicalConditionLayoutService.insertRingPhysicalConditionLayout(ringPhysicalConditionLayout));
    }

    /**
     * 修改身体状况布局
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_physical_condition_layout:edit')")
    @Log(title = "身体状况布局", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingPhysicalConditionLayout ringPhysicalConditionLayout)
    {
        return toAjax(ringPhysicalConditionLayoutService.updateRingPhysicalConditionLayout(ringPhysicalConditionLayout));
    }

    /**
     * 删除身体状况布局
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_physical_condition_layout:remove')")
    @Log(title = "身体状况布局", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringPhysicalConditionLayoutService.deleteRingPhysicalConditionLayoutByIds(ids));
    }
}
